package com.yu.newsSys.listener;

import com.yu.newsSys.constants.ListenerConstants;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

@WebListener
public class SpringServletContextListener implements ServletContextListener {
    @Override
    public void contextInitialized(ServletContextEvent sce) {
        ServletContext context = sce.getServletContext();

        ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring3.xml");

        context.setAttribute(ListenerConstants.SPRINT, applicationContext);
    }
}
